package com.ly.cloud.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.plugins.Page;
import com.ly.cloud.common.mybatisplus.plugins.PageInfo;
import com.ly.cloud.dto.StudentInfoDto;
import com.ly.cloud.service.StudentInfoService;
import com.ly.cloud.vo.GradeVo;
import com.ly.cloud.vo.RegisterInfoVo;
import com.ly.cloud.vo.StudentDetailInfoVo;
import com.ly.cloud.vo.StudentInfoVo;
import com.ly.cloud.vo.XjYdVo;
import com.ly.cloud.web.utils.WebResponse;

/**
 * Description:该控制器用来用来操作学生基本信息
 * @author luhuacong
 * @date: 2018年12月21日
 */
@RestController
@RequestMapping("/studentInfo")
public class StudentInfoController {

	@Resource
	private StudentInfoService studentInfoService;
	
	/**(non-Javadoc)
	 * Title: insertStudentInfo
	 * Description: 
	 * 添加学生信息
	 * @param dto 条件封装对象
	 * @param loginUserName 登录者
	 * @return  boolean
	 * @date: 2018年12月21日
	 * @author luhuacong
	 */
	@RequestMapping(value = "/insertXsInfo", method = RequestMethod.POST)
	public WebResponse<Boolean> insertXsInfo(@RequestHeader(required=false,value = "loginUserName") String loginUserName,@RequestBody StudentInfoDto dto){
		boolean isSuccess = studentInfoService.insertStudentInfo(dto, loginUserName);
		return new WebResponse<Boolean>().success(isSuccess);
	}
	
	/**(non-Javadoc)
	 * Title: deleteXsInfoByIds
	 * Description: 
	 * 根据学生id集合批量删除学生
	 * @param xsidList 学生id集合
	 * @return  成功删除的个数
	 * @date: 2018年12月21日
	 * @author luhuacong
	 */
	@RequestMapping(value = "/deleteXsInfoByIds", method = RequestMethod.POST)
	public WebResponse<Integer> deleteXsInfoByIds(@RequestBody List<String> xsidList){
		Integer count = studentInfoService.deleteXsInfoByIds(xsidList);
		return new WebResponse<Integer>().success(count);
	}
	
	/**(non-Javadoc)
	 * Title: updateXsInfo
	 * Description: 
	 * 修改学生信息
	 * @param dto 条件封装对象
	 * @param loginUserName 修改人
	 * @return  boolean
	 * @date: 2018年12月21日
	 * @author luhuacong
	 */
	@RequestMapping(value = "/updateXsInfo", method = RequestMethod.POST)
	public WebResponse<Boolean> updateXsInfo(@RequestHeader(required=false,value = "loginUserName") String loginUserName,@RequestBody StudentInfoDto dto){
		boolean isSuccess = studentInfoService.updateXsInfo(dto, loginUserName);
		return new WebResponse<Boolean>().success(isSuccess);
	}
	
	/** 
	 * Method Name:selectXsListByCon
	 * Description:根据条件查询学生信息
	 * @param page 
	 * @param dto 条件封装对象
	 * @return PageInfo<StudentInfoVo>
	 * @author LuHuaCong
	 * @date: 2018年12月22日
	 */
	@RequestMapping(value = "/selectXsListByCon", method = RequestMethod.POST)
	public  WebResponse<PageInfo<StudentInfoVo>> selectXsListByCon(@RequestBody StudentInfoDto dto){
		Page<StudentInfoVo> page = studentInfoService.selectXsListByCon(new Page<StudentInfoVo>(dto.getPageNum(), dto.getPageSize()), dto);
		return new WebResponse<PageInfo<StudentInfoVo>>().success(PageInfo.toPageInfo(page));
	}
	
	/** 
	 * MethodName:selectRegisterInfo
	 * Description:根据学号查询注册状态
	 * @param pageNum 当前页
	 * @param pageSize 每页显示条数
	 * @param xsid 学号
	 * @return List<RegisterInfoVo>
	 * @author LuHuaCong
	 * @date: 2018年12月24日
	 */
	@RequestMapping(value = "/selectRegisterInfo", method = RequestMethod.GET)
	public  WebResponse<PageInfo<RegisterInfoVo>> selectRegisterInfo(@RequestParam int pageNum, @RequestParam int pageSize,String xsid){
		Page<RegisterInfoVo> page = studentInfoService.selectRegisterInfo(new Page<RegisterInfoVo>(pageNum, pageSize), xsid);
		return new WebResponse<PageInfo<RegisterInfoVo>>().success(PageInfo.toPageInfo(page));
	}
	
	/** 
	 * MethodName:
	 * selectXjYdInfo
	 * Description:根据学号查询学籍异动信息
	 * @param xsid 学号
	 * @return Page<XjYdVo>
	 * @author LuHuaCong
	 * @date: 2018年12月24日
	 */
	@RequestMapping(value = "/selectXjYdInfo", method = RequestMethod.GET)
	public  WebResponse<PageInfo<XjYdVo>> selectXjYdInfo(@RequestParam int pageNum, @RequestParam int pageSize,String xsid){
		Page<XjYdVo> page = studentInfoService.selectXjYdInfo(new Page<XjYdVo>(pageNum, pageSize), xsid);
		return new WebResponse<PageInfo<XjYdVo>>().success(PageInfo.toPageInfo(page));
	}
	
	/** 
	 * MethodName:selectGradeInfo
	 * Description:根据学号查询学生成绩信息
	 * @param page
	 * @param xsid 学号
	 * @return List<GradeVo>
	 * @author LuHuaCong
	 * @date: 2018年12月24日
	 */
	@RequestMapping(value = "/selectGradeInfo", method = RequestMethod.GET)
	public  WebResponse<PageInfo<GradeVo>> selectGradeInfo(@RequestParam int pageNum, @RequestParam int pageSize,@RequestParam String xsid){
		Page<GradeVo> page = studentInfoService.selectGradeInfo(new Page<GradeVo>(pageNum, pageSize), xsid);
		return new WebResponse<PageInfo<GradeVo>>().success(PageInfo.toPageInfo(page));
	}
	
	/** 
	 * MethodName:selectXsXxXxByid
	 * Description:根据学号查询学生详细信息
	 * @param xsid 学号
	 * @return StudentDetailInfoVo
	 * @date: 2018年1月8日
	 */
	@RequestMapping(value = "/selectXsXxXxByid/{xsid}", method = RequestMethod.GET)
	public  WebResponse<StudentDetailInfoVo> selectXsXxXxByid(@PathVariable("xsid") String xsid){
		StudentDetailInfoVo vo = studentInfoService.selectXsXxXxByid(xsid);
		return new WebResponse<StudentDetailInfoVo>().success(vo);
	}
}
